package com.codi.bus.core.dao.impl;

import com.codi.base.dao.BaseDAOImpl;
import com.codi.bus.core.dao.OrderFundDao;
import com.codi.bus.core.domain.OrderFund;
import com.codi.bus.core.vo.query.OrderFundQueryVo;
import com.github.pagehelper.PageRowBounds;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository("orderFundDao")
public class OrderFundDaoImpl extends BaseDAOImpl<OrderFund> implements OrderFundDao {

    @Override
    public void add(OrderFund entity) {
        entity.setCreateDate(new Date());
        entity.setIsValid(true);
        this.insert(entity);
    }

    @Override
    public void updateFund(OrderFund entity) {
        entity.setLastUpdatedDate(new Date());
        this.update(entity);
    }

    @Override
    public OrderFund getEntityByExtApplyNo(String externalApplyNo) {
        return this.getObject(OrderFund.class.getName() + ".selectByExternalApplyNo", externalApplyNo);
    }

    @Override
    public List<OrderFund> query(OrderFundQueryVo record) {


        return this.getSqlSession().selectList(generateStatement("query"), record);
    }

    @Override
    public void updateStatus(OrderFund entity) {
        entity.setLastUpdatedDate(new Date());
        this.update(OrderFund.class.getName() + ".updateStatus", entity);
    }

}
